<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>申请提现</title>
<link rel="stylesheet" type="text/css" href="/style/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/style/css/swiper.min.css"/>
<link rel="stylesheet" type="text/css" href="/style/css/xshop.css?ver=20170916" />
<script src="/style/js/jquery-1.12.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/js/xShop.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div class="outwrap">
  <!--top-->	
	<!-- <div class="topbar clearfix topvh">
		<a href="/myshop/my_bag" class="btn-back">
			<i class="ico-back"></i><span>提现申请</span>
		</a>
	</div> -->
  <form id="form_tx">
  <div class="meinner-adr-add">
    
    <div class="tixian-edu">
      <p class="kt">可用余额<span><b><?=number_format($this->balance['revenue'],2,".","")?></b></span></p>
    </div>
    
    <div class="tixian-minf mt20">
      <dl class="clearfix">
        <dt>提现类型</dt>
        <dd>
          <span class="psfs">提现到微信零钱</span>
        </dd>
      </dl>
      <dl class="clearfix">
        <dt>提现金额</dt>
        <dd>
          <input type="tel" class="txt" id="_money"/>
        </dd>
      </dl>      
    </div>
  
    <div class="tixian-edu mt20">
      <p class="sm"><b>提现说明</b><br><br>
      1、最小金额10元<br>
      2、提交申请后系统将自动为您处理，如果长时间未到账请联系客服</p>
    </div>
    
    <div class="btnwrap">
      <input type="button" class="btn-mexl btn-bc"  id="submit_tx" value="申请" />
    </div>
  </div>
</form>
</div>
<link rel="stylesheet" href="/style/css/sweet-alert.css" />
<script type="text/javascript" src="/style/js/sweet-alert.min.js"></script>
<script type="text/javascript">
var _min = 10,
    _amount = <?=$this->balance['revenue'] > 0 ? $this->balance['revenue'] : 0?>;
$("#submit_tx").click(function() {
    var money = parseInt($("#_money").prop("value"));
    if ($("#_money").val() == "") {
        swal("请输入提现金额");
        return false;
    } else {
        if (!$.isNumeric($("#_money").val())) {
            swal("提现金额必须是数字");
            return false;
        } else if ($("#_money").val() < _min) {
            swal("金额不能少于10元");
            return false;
        }
    }
    if (money < _min) {
        swal("金额不能少于" + _min + "元");
        return false;
    } else if (money > _amount) {
        swal("金额不能大于可用余额");
        return false;
    } else {
        $.post("/wallet/ajax", {
            "act": "dowithdraw",
            "money": $("#_money").prop("value"),
            "mr": Math.random()
        }, function(json) {
            console.log(json);
            if (json.code == 200) {
                swal("提交申请成功！", "系统自动处理，请您耐心等待", "success");
                setTimeout(function() {
                    window.location.reload();
                }, 2100);
            } else {
                switch (json.code) {
                    case 407:
                        swal("金额不能少于10元");
                        break;
                    case 408:
                        swal("可用余额不足");
                        break;
                    case 409:
                        swal("保存提现申请失败");
                        break;
                    case 410:
                        swal("冻结资金失败");
                        break;
                    case 411:
                        swal("保存资金明细失败");
                        break;
                }
            }
        }, "json");
    }
});
</script>
</body>
</html>
